<div class="container" id="ajax_content">
    <?php
        include 'header2.php';
    ?>
    <div class="content">
    	<div class="headcontent">
            <span class="randomtext" style="margin-left:50px">Hi, 
            <?php
                global $session;
                $user_id = $session->get('userid');
                $sql="SELECT fullname FROM user WHERE iduser='$user_id'";
		$result=mysql_query($sql);
		while($res = mysql_fetch_array($result)) {
                    $nama = $res['fullname'];
		}
		echo $nama;
            ?>
            </span>
            <span class="randomtext" style="padding-left:900px">PROFILE</span>
        	<hr/>
        </div>
    	<div class="leftcontent" style="width:250px; border-right-style: groove">
            <div style="margin-left: 40px">
                <div class="fotoitem">
                    <img src="<?php echo $pimg;?>" alt="profpic" height="200" width="150" />
                </div>
          </div>
            <div class="clearboth"></div>
            <div>
                <div class="randomtext" style="margin-bottom: 10px; margin-top: 15px">Personal Information</div>
                <div class="item2">
                	<label>Full Name :</label><br/>
                        <label style="text-align:left"><?php echo $user;?></label>
                </div>
                <div class="item2">
                	<label>Birth Date :</label><br/>
                        <label style="text-align:left"><?php echo $pbirthday;?></label>
                </div>
                <div class="item2">
                	<label>E-mail :</label><br/>
                        <label style="text-align:left"><?php echo $pemail;?></label>
                </div>
                <div class="item2">
                	<label>Gender :</label><br/>
                        <label style="text-align:left"><?php if ($pgender == 'P') {echo "Pria";} else {echo "Wanita";};?></label>
                </div>
                <div class="item2">
                	<label>Location :</label><br/>
                        <label style="text-align:left"><?php echo $plocation;?></label>
                </div>
                <div class="item2">
                    <a href="<?php echo BASE_PATH;?>eprof/index">
                    <button name="editprof">Edit Personal Information</button>
                    </a>
                    <!--<input type="button" name="editprof" onclick="gotoeditprofilepage();" value="Edit Personal Information">
                    <button type="button" name="editprof" onclick="gotoeditprofilepage();">Edit Personal Information</button>-->
                </div>
            </div>
        </div>
        <div class="leftcontent" style="width:730px; border-right-style: groove">
            <div>
                <div class="items" style="float:left">
                        <label>Accessibility</label>
                </div>
                <div class="items">
                        <select>
                        <option>Everyone</option>
                        <option>Follower</option>
                        <option>Private</option>
                        </select>
                </div>
                <div class="clearboth"></div>
            </div>
            <form action="<?php echo BASE_PATH . "profile/postwall" ?>" method="post">
                <div class="wallpost">
                    <div class="post">
                        <textarea rows="2" cols="72" name="post"></textarea>
                    </div>
                    <div>
                        <button type="submit" name="post_wall">Post</button>
                    </div>
                </div>
            </form>
            <div>
                <?php
                    $query = 'SELECT * FROM post_wall WHERE idwall=\''.mysql_real_escape_string($idwall).'\'';
                    $result = mysql_query($query);
                    if (count($result) != 0) {
                        while ($res = mysql_fetch_array($result)) {
                            $query2 = 'SELECT * FROM user WHERE iduser=\''.mysql_real_escape_string($res['id_writer']).'\'';
                            $result2 = mysql_query($query2);
                            $res2 = mysql_fetch_array($result2);
                            echo '<div class="wallpost">
                                    <div class="post">
                                        <div class="postitem" style="width: 65px">
                                            <div class="fotoitem">
                                                <img src="images/pudy.jpg" alt="pudy cantik" height="50" width="50" />                            </div>
                                            </div>
                                        <div class="postitem" style="width: 450px">
                                            <label>'.$res2['fullname'].'</label><br/>
                                            <label>'.$res['isi'].'</label><br/>
                                        </div>
                                        <div class="postitem">
                                            <label>Delete</label>
                                        </div>
                                        <div class="clearboth"></div>
                                    </div>';
                            $query3 = 'SELECT * FROM komen_wall WHERE idpost=\''.mysql_real_escape_string($res['idpost']).'\'';
                            $result3 = mysql_query($query3);
                            if (count($result3) != 0) {
                                while ($res3 = mysql_fetch_array($result3)) {
                                    $query4 = 'SELECT * FROM user WHERE iduser=\''.mysql_real_escape_string($res3['id_writer']).'\'';
                                    $result4 = mysql_query($query4);
                                    $res4 = mysql_fetch_array($result4);
                                    echo '<div class="post">
                                            <div class="postitem" style="width: 65px">
                                                <div class="fotoitem">
                                                    <img src="images/pudy.jpg" alt="pudy cantik" height="30" width="30" />                            </div>
                                                </div>
                                            <div class="postitem" style="width: 450px">
                                                <label>'.$res4['fullname'].'</label><br/>
                                                <label>'.$res3['isi'].'</label><br/>
                                            </div>
                                            <div class="postitem">
                                                <label>Delete</label>
                                            </div>
                                            <div class="clearboth"></div>
                                        </div>';
                                }
                            }
                            //$idpost = $res3[0]['Komen_wall']['idpost'];
                            $idpost = $res['idpost'];
                            //echo $idpost;
                            echo '<div class="post">
                                    <form action="'.BASE_PATH.'profile/komenwall/'.$idpost.'" method="post">
                                        <div class="post">
                                            <textarea rows="2" cols="72" name="post"></textarea>
                                        </div>
                                        <div>
                                            <button type="submit">Post</button>
                                        </div>
                                    </form>
                                  </div>
                                </div>';
                        }
                    }
                ?>
                <!--<div class="wallpost">
                    <div class="post">
                        <div class="postitem" style="width: 65px">
                            <div class="fotoitem">
                                <img src="images/pudy.jpg" alt="pudy cantik" height="50" width="50" />                            </div>
                      </div>
                        <div class="postitem" style="width: 450px">
                            <label>Pudy Prima</label><br/>
                            <label>Hari ini menyenangkan</label><br/>
                            <label>19 Maret 2011</label>
                        </div>
                        <div class="postitem">
                            <label>Delete</label>
                        </div>
                        <div class="clearboth"></div>
                    </div>
                    <div class="post">
                        <div class="postitem" style="width: 65px">
                            <div class="fotoitem">
                                <img src="images/pudy.jpg" alt="pudy cantik" height="40" width="40" />                            </div>
                      </div>
                        <div class="postitem" style="width: 450px">
                            <label>Pudy Prima</label><br/>
                            <label>Iya menyenangkan, labil ngomenin post sendiri</label><br/>
                            <label>19 Maret 2011</label>
                        </div>
                        <div class="postitem">
                            <label>Delete</label>
                        </div>
                        <div class="clearboth"></div>
                    </div>
                    <div class="post">
                        <div class="post">
                            <textarea rows="2" cols="72" name="post"></textarea>
                        </div>
                        <div>
                            <button type="submit">Post</button>
                        </div>
                    </div>
                </div>
                <div class="wallpost">
                    <div class="post">
                        <div class="postitem" style="width: 65px">
                            <div class="fotoitem">
                                <img src="images/pudy.jpg" alt="pudy cantik" height="50" width="50" />                            </div>
                      </div>
                        <div class="postitem" style="width: 450px">
                            <label>Pudy Prima</label><br/>
                            <label>Hari ini menyebalkan X(</label><br/>
                            <label>18 Maret 2011</label>
                        </div>
                        <div class="postitem">
                            <label>Delete</label>
                        </div>
                        <div class="clearboth"></div>
                    </div>
                    <div class="post">
                        <div class="post">
                            <textarea rows="2" cols="72" name="post"></textarea>
                        </div>
                        <div>
                            <button type="submit">Post</button>
                        </div>
                    </div>
                </div>-->
            </div>
        </div>
        <div class="leftcontent" style="width:250px; padding-left: 20px">
            <div class="right1" style="margin-bottom: 20px; margin-top: 20px">
                <div class="randomtext">Following</div>
                <div>
                     <?php
                                    global $session;
                                    $index = $session->get('userid');

                                    $sql_follower = "SELECT idfollowed FROM follow_user WHERE iduser='$index'";
                                    $result_tag = mysql_query($sql_follower);
                                    while($res_tag = mysql_fetch_array($result_tag)){
                                            $nama_tag = $res_tag['idfollowed'];
                                            $sql_name = "SELECT * FROM user WHERE iduser='$nama_tag'";
                                            $result_name = mysql_query($sql_name);
                                            while($res = mysql_fetch_array($result_name)) {
                                    			$pic = $res['fullname'];
												$pp = $res['pp'];
                            }
                    ?>
                		<a href="<?php echo BASE_PATH;?>pother/index/<?php echo $nama_tag?>">

                        	<img src="<?php echo $pp?>"  height="50" width="50" style="margin-top:10px; " />

                        </a>
                <?php
						}
				?>
              </div>
            </div>
            <div class="right1" style="margin-bottom: 25px">
                <div class="randomtext">Follower</div>
                <div>
                	<?php
						global $session;

						$sql_follower = "SELECT iduser FROM follow_user WHERE idfollowed='$index'";
						$result_tag = mysql_query($sql_follower);
						while($res_tag = mysql_fetch_array($result_tag)){
							$nama_tag = $res_tag['iduser'];
							$sql_name = "SELECT * FROM user WHERE iduser='$nama_tag'";
							$result_name = mysql_query($sql_name);
							while($res = mysql_fetch_array($result_name)) {
                				$pic = $res['fullname'];
								$pp = $res['pp'];
            				}
				?>
                		<a href="<?php echo BASE_PATH;?>pother/index/<?php echo $nama_tag?>">
                		<img src="<?php echo $pp?>"  height="50" width="50" style="margin-top:10px; " />
                        </a>
                <?php
						}
				?>
              </div>
            </div>
            <div class="clearboth"></div>
            <div class="right1" style="padding-bottom: 15px; border-bottom-style: groove">

            </div>
            <div class="right1" style="margin-top: 35px">
                <div class="randomtext">Photos</div>
                <div>
                    <?php
						global $session;

						$sql = "SELECT * FROM foto WHERE iduser='$index'";
						$result_tag = mysql_query($sql);
						while($res_tag = mysql_fetch_array($result_tag)){
							$id_foto = $res_tag['idfoto'];
							$deskripsi = $res_tag['deskripsi'];
							$pic = $res_tag['pic'];
					?>
                		<a href="<?php echo BASE_PATH;?>pdetail/index/<?php echo $id_foto?>">

                        	<img src="<?php echo $pic?>" height="50" width="50" style="margin-top:10px; " />


                        </a>
                <?php
						}
				?>
              </div>
            </div>
            <div class="clearboth"></div>
            <div class="right1" style="padding-bottom: 15px; border-bottom-style: groove">
            	
            </div>
            <div class="right1" style="margin-top: 35px">
                <div class="randomtext">Photos</div>
                <div>
                    <?php 
						global $session;
						
						$sql = "SELECT deskripsi,idfoto FROM foto WHERE iduser='$index'";
						$result_tag = mysql_query($sql);
						while($res_tag = mysql_fetch_array($result_tag)){
							$id_foto = $res_tag['idfoto'];
							$deskripsi = $res_tag['deskripsi'];
					?>
                		<a href="<?php echo BASE_PATH;?>pdetail/index/<?php echo $id_foto?>">
                		<div class="fotoitem">
                        	<div class="randomtext"> <?php echo $deskripsi?> </div>
                        </div>
                        </a>
                <?php
						}
				?>
              </div>
            </div>
            <div class="clearboth"></div>
        </div>
        <div class="clearboth"></div>
    </div>
    <div class="footer"></div>
</div>
